import maya.cmds as mc


class change_vis_models():
    def __init__(self):
        pass
        
    def change_vis_models(self):
        renderGrp = 'body_render_grp'
        donoutouch = 'DO_NOT_TOUCH'
        gro_grp = 'geometry'
        vis_ctrl = 'ac_cn_settings'
        body_vis_attr = 'body_res'
        body_geoGrp = 'body_geo_grp'
        
        if mc.objExists(body_geoGrp) == 0 :
            mc.group( em=True , n = body_geoGrp)
            mc.parent( body_geoGrp , gro_grp )
        
        if mc.objExists(renderGrp) == 1:
            pass
            
        else:
            mc.group(em =True , n= renderGrp )
            
            mc.parent(renderGrp , gro_grp )
            
            self.LZ_serDrivenKey_02( driverAttr = str(vis_ctrl)+ '.'+str(body_vis_attr), drivenAttr = str(renderGrp)+ '.visibility' ,driverV = [1,2] , drivenV = [ 0 , 1 ] ,inType = 'linear' ,outType = 'linear' , preV = 'constant', poiV = 'constant')
    
            self.LZ_serDrivenKey_02( driverAttr = str(vis_ctrl)+ '.'+str(body_vis_attr), drivenAttr = str(body_geoGrp)+ '.visibility' ,driverV = [0,1,2] , drivenV = [0, 1 , 0 ] ,inType = 'linear' ,outType = 'linear' , preV = 'constant', poiV = 'constant')
    
    
    
    
    def LZ_serDrivenKey_02(self,driverAttr = 'xxx.aaa', drivenAttr = 'xxx.bbb' ,driverV = [0,1] , drivenV = [ 0 , 1 ] ,inType = 'linear' ,outType = 'linear' , preV = 'cycleRelative', poiV = 'constant'):
        
        if len(driverV) == len(drivenV) :
            for i in range(len(driverV)) :
                mc.setDrivenKeyframe(  drivenAttr, cd= driverAttr,dv = driverV[i],v = drivenV[i] , inTangentType = inType ,outTangentType = outType )  
                
                #ani_node = self.findNode_animation( driver = driverAttr , driven = drivenAttr )
                #
                #self.set_key_Infinity_type( aniCurve = ani_node ,priValue = preV , poiValue = poiV )
                
    def set_key_Infinity_type(self,aniCurve = '' ,priValue = 'cycle', poiValue = 'cycle'):  ##  cycleRelative   cycle   constant
        mc.selectKey( aniCurve )
        mc.setInfinity(  pri = priValue, poi = poiValue )
            